package org.bigdata.framework.core.controller;

import javax.servlet.http.HttpServletRequest;

import org.bigdata.framework.core.model.Category;
import org.bigdata.framework.core.model.Config;
import org.bigdata.framework.core.model.Course;
import org.bigdata.framework.core.model.Live;
import org.bigdata.framework.core.model.Online;
import org.bigdata.framework.core.protocol.IBaseService;
import org.bigdata.framework.core.protocol.IPublicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import springfox.documentation.annotations.ApiIgnore;

@ApiIgnore
@Controller
public class ToPageController extends BaseController{

	@Autowired
	private IBaseService baseService;
	@Autowired
	private IPublicService publicService;
	
	@RequestMapping("index.html")
	public String index(HttpServletRequest request, Model model) {
		return "/modules/index";
	}
	@RequestMapping("login2.html")
	public String login2(HttpServletRequest request, Model model) {
		return "/modules/login2";
	}
	
	@RequestMapping("lanmu.html")
	public String lanmu(HttpServletRequest request, Model model) {
		return "/modules/jianxue/lanmu";
	}

	@RequestMapping("kecheng.html")
	public String kecheng(HttpServletRequest request, Model model) {
		return "/modules/jianxue/kecheng";
	}
	
	@RequestMapping("weike.html")
	public String weike(HttpServletRequest request, Model model) {
		return "/modules/jianxue/weike";
	}
	
	@RequestMapping("tiku.html")
	public String tiku(HttpServletRequest request, Model model) {
		return "/modules/jianxue/tiku";
	}
	
	@RequestMapping("timu.html")
	public String timu(HttpServletRequest request, Model model) {
		return "/modules/jianxue/timu";
	}
	
	@RequestMapping("wangban.html")
	public String wangban(HttpServletRequest request, Model model) {
		return "/modules/jianxue/wangban";
	}
	
	@RequestMapping("zhibo.html")
	public String zhibo(HttpServletRequest request, Model model) {
		return "/modules/jianxue/zhibo";
	}
	
	@RequestMapping("member.html")
	public String member(HttpServletRequest request, Model model) {
		return "/modules/jianxue/member";
	}
	@RequestMapping("message.html")
	public String message(HttpServletRequest request, Model model) {
		return "/modules/jianxue/message";
	}
	
	@RequestMapping("opinion.html")
	public String opinion(HttpServletRequest request, Model model) {
		return "/modules/jianxue/opinion";
	}
	@RequestMapping("advertising.html")
	public String advertising(HttpServletRequest request, Model model) {
		return "/modules/jianxue/advertising";
	}
	
	@RequestMapping("video.html")
	public String video(HttpServletRequest request, Model model) {
		return "/modules/jianxue/video";
	}

	@RequestMapping("configuration.html")
	public String configuration(HttpServletRequest request, Model model) {
		return "/modules/jianxue/configuration";
	}
	
	@RequestMapping("log.html")
	public String log(HttpServletRequest request, Model model) {
		return "/modules/jianxue/log";
	}
	
	@RequestMapping("shenhe.html")
	public String shenhe(HttpServletRequest request, Model model) {
		String type = request.getParameter("type");
		String ids = request.getParameter("ids");
		String auditType = request.getParameter("auditType");
		request.setAttribute("type", type);
		request.setAttribute("ids", ids);
		request.setAttribute("auditType", auditType);
		return "/modules/jianxue/shenhe";
	}
	
	@RequestMapping("lanmu-add.html")
	public String lanmuAdd(HttpServletRequest request, Model model) {
		String id = request.getParameter("id");
		Category category = new Category();
		if(id!=null && id !=null && !"".equals(id) && !"0".equals(id)){
			category = publicService.findCategory(Integer.parseInt(id));
		}
		request.setAttribute("category", category);
		return "/modules/jianxue/lanmu_add";
	}
	@RequestMapping("kecheng-detail.html")
	public String kechengDetail(HttpServletRequest request, Model model) {
		String id = request.getParameter("id");
		if(id!=null && id !=null && !"".equals(id) && !"0".equals(id)){
			request.setAttribute("id", id);
		}else{
			request.setAttribute("id", "");
		}
		return "/modules/jianxue/kecheng_detail";
	}
	@RequestMapping("kecheng-pingjia.html")
	public String kechengPingjia(HttpServletRequest request, Model model) {
		String id = request.getParameter("id");
		if(id!=null&&!"undefined".equals(id)&&!"null".equals(id)&&!"0".equals(id)){
			request.setAttribute("id", id);
		}else{
			request.setAttribute("id", "");
		}
		return "/modules/jianxue/kecheng_pingjia";
	}
	@RequestMapping("kecheng-zujuan.html")
	public String kechengZujuan(HttpServletRequest request, Model model) {
		return "/modules/jianxue/kecheng_zujuan";
	}
	@RequestMapping("weike-detail.html")
	public String weikeDetail(HttpServletRequest request, Model model) {
		String id = request.getParameter("id");
		if(id!=null && id !=null && !"".equals(id) && !"0".equals(id)){
			request.setAttribute("id", id);
		}else{
			request.setAttribute("id", "");
		}
		return "/modules/jianxue/weike_detail";
	}
	@RequestMapping("weike-zujuan.html")
	public String weikeZujuan(HttpServletRequest request, Model model) {
		return "/modules/jianxue/weike_zujuan";
	}
	@RequestMapping("tiku-detail.html")
	public String tikuDetail(HttpServletRequest request, Model model) {
		String id = request.getParameter("id");
		if(id!=null && id !=null && !"".equals(id) && !"0".equals(id)){
			request.setAttribute("id", id);
		}else{
			request.setAttribute("id", "");
		}
		return "/modules/jianxue/tiku_detail";
	}
	@RequestMapping("timu-detail.html")
	public String timuDetail(HttpServletRequest request, Model model) {
		String id = request.getParameter("id");
		if(id!=null && id !=null && !"".equals(id) && !"0".equals(id)){
			request.setAttribute("id", id);
		}else{
			request.setAttribute("id", "");
		}
		return "/modules/jianxue/timu_detail";
	}
	@RequestMapping("wangban-detail.html")
	public String wangbanDetail(HttpServletRequest request, Model model) {
		String id = request.getParameter("id");
		if(id!=null && id !=null && !"".equals(id) && !"0".equals(id)){
			request.setAttribute("id", id);
		}else{
			request.setAttribute("id", "");
		}
		return "/modules/jianxue/wangban_detail";
	}
	@RequestMapping("wangban-pingjia.html")
	public String wangbanPingjia(HttpServletRequest request, Model model) {
		String id = request.getParameter("id");
		if(id!=null && id !=null && !"".equals(id) && !"0".equals(id)){
			request.setAttribute("id", id);
		}else{
			request.setAttribute("id", "");
		}
		return "/modules/jianxue/wangban_pingjia";
	}
	@RequestMapping("zhibo-detail.html")
	public String zhiboDetail(HttpServletRequest request, Model model) {
		String id = request.getParameter("id");
		if(id!=null && id !=null && !"".equals(id) && !"0".equals(id)){
			request.setAttribute("id", id);
		}else{
			request.setAttribute("id", "");
		}
		return "/modules/jianxue/zhibo_detail";
	}
	@RequestMapping("zhibo-suitangkao.html")
	public String zhiboSuitangkao(HttpServletRequest request, Model model) {
		return "/modules/jianxue/zhibo_suitangkao";
	}
	@RequestMapping("message-add.html")
	public String messageAdd(HttpServletRequest request, Model model) {
		String id = request.getParameter("id");
		if(id!=null && id !=null && !"".equals(id) && !"0".equals(id)){
			request.setAttribute("id", id);
		}else{
			request.setAttribute("id", "");
		}
		return "/modules/jianxue/message_add";
	}
	@RequestMapping("opinion-fankui.html")
	public String opinionFankui(HttpServletRequest request, Model model) {
		String id = request.getParameter("id");
		if(id!=null && id !=null && !"".equals(id) && !"0".equals(id)){
			request.setAttribute("id", id);
		}else{
			request.setAttribute("id", "");
		}
		return "/modules/jianxue/opinion_fankui";
	}
	@RequestMapping("advertising-detail.html")
	public String advertisingDetail(HttpServletRequest request, Model model) {
		String id = request.getParameter("id");
		if(id!=null && id !=null && !"".equals(id) && !"0".equals(id)){
			request.setAttribute("id", id);
		}else{
			request.setAttribute("id", "");
		}
		return "/modules/jianxue/advertising_detail";
	}
	@RequestMapping("advertising-kecheng.html")
	public String advertisingKecheng(HttpServletRequest request, Model model) {
		return "/modules/teacher/advertising_kecheng";
	}
	@RequestMapping("video-onlineplay.html")
	public String vidoOnlineplay(HttpServletRequest request, Model model) {
		String id = request.getParameter("id");
		if(id!=null && id !=null && !"".equals(id) && !"0".equals(id)){
			request.setAttribute("id", id);
		}else{
			request.setAttribute("id", "");
		}
		return "/modules/jianxue/video_onlineplay";
	}
	@RequestMapping("configuration-add.html")
	public String configurationAdd(HttpServletRequest request, Model model) {
		Config config=new Config();
		String id = request.getParameter("id");
		if(id!=null && id !=null && !"".equals(id) && !"0".equals(id)){
			config = publicService.findConfig(Integer.parseInt(id));
			request.setAttribute("config", config);
		}else{
			request.setAttribute("config", config);
		}
		
		return "/modules/jianxue/configuration_add";
	}
	@RequestMapping("order.html")
	public String order(HttpServletRequest request, Model model) {
		String id = request.getParameter("id");
		if(id!=null && id !=null && !"".equals(id) && !"0".equals(id)){
			request.setAttribute("id", id);
		}else{
			request.setAttribute("id", "");
		}
		return "/modules/jianxue/order";
	}
	
	
	//==============================teacher=================================
	@RequestMapping("kecheng-teacher.html")
	public String kechengTeacher(HttpServletRequest request, Model model) {
		return "/modules/teacher/kecheng";
	}
	
	@RequestMapping("weike-teacher.html")
	public String weikeTeacher(HttpServletRequest request, Model model) {
		String courseId = request.getParameter("courseId");
		if(courseId==null){
			request.setAttribute("courseId", "");
		}else{
			request.setAttribute("courseId", courseId);
		}
		return "/modules/teacher/weike";
	}
	
	@RequestMapping("tiku-teacher.html")
	public String tikuTeacher(HttpServletRequest request, Model model) {
		return "/modules/teacher/tiku";
	}
	
	@RequestMapping("timu-teacher.html")
	public String timuTeacher(HttpServletRequest request, Model model) {
		return "/modules/teacher/timu";
	}
	
	@RequestMapping("wangban-teacher.html")
	public String wangbanTeacher(HttpServletRequest request, Model model) {
		return "/modules/teacher/wangban";
	}
	
	@RequestMapping("zhibo-teacher.html")
	public String zhiboTeacher(HttpServletRequest request, Model model) {
		String classesonlineId = request.getParameter("classesonlineId");
		if(classesonlineId==null){
			request.setAttribute("classesonlineId", "");
		}else{
			request.setAttribute("classesonlineId", classesonlineId);
		}
		return "/modules/teacher/zhibo";
	}
	@RequestMapping("advertising-teacher.html")
	public String advertisingTeacher(HttpServletRequest request, Model model) {
		return "/modules/teacher/advertising";
	}
	
	
	
	
	@RequestMapping("kecheng-teacher-detail.html")
	public String kechengTeacherDetail(HttpServletRequest request, Model model) {
		String id = request.getParameter("id");
		if(id!=null&&!"undefined".equals(id)&&!"null".equals(id)&&!"0".equals(id)){
			request.setAttribute("id", id);
		}else{
			request.setAttribute("id", "");
		}
		return "/modules/teacher/kecheng_detail";
	}
	@RequestMapping("queryuser.html")
	public String queryuser(HttpServletRequest request, Model model) {
		String id = request.getParameter("id");
		String type = request.getParameter("type");
		if(id!=null&&!"undefined".equals(id)&&!"null".equals(id)&&!"0".equals(id)){
			request.setAttribute("id", id);
		}else{
			request.setAttribute("id", "");
		}
		request.setAttribute("type", type);
		return "/modules/teacher/queryuser";
	}
	@RequestMapping("kecheng-teacher-pingjia.html")
	public String kechengTeacherPingjia(HttpServletRequest request, Model model) {
		String id = request.getParameter("id");
		if(id!=null&&!"undefined".equals(id)&&!"null".equals(id)&&!"0".equals(id)){
			request.setAttribute("id", id);
		}else{
			request.setAttribute("id", "");
		}
		return "/modules/teacher/kecheng_pingjia";
	}
	@RequestMapping("kecheng-teacher-zujuan.html")
	public String kechengTeacherZujuan(HttpServletRequest request, Model model) {
		return "/modules/teacher/kecheng_zujuan";
	}
	@RequestMapping("weike-teacher-detail.html")
	public String weikeTeacherDetail(HttpServletRequest request, Model model) {
		String id = request.getParameter("id");
		if(id!=null && id !=null && !"".equals(id) && !"0".equals(id)){
			request.setAttribute("id", id);
		}else{
			request.setAttribute("id", "");
		}
		return "/modules/teacher/weike_detail";
	}
	@RequestMapping("weike-teacher-zujuan.html")
	public String weikeTeacherZujuan(HttpServletRequest request, Model model) {
		return "/modules/teacher/weike_zujuan";
	}
	@RequestMapping("tiku-teacher-detail.html")
	public String tikuTeacherDetail(HttpServletRequest request, Model model) {
		String id = request.getParameter("id");
		if(id!=null && id !=null && !"".equals(id) && !"0".equals(id)){
			request.setAttribute("id", id);
		}else{
			request.setAttribute("id", "");
		}
		return "/modules/teacher/tiku_detail";
	}
	@RequestMapping("timu-teacher-detail.html")
	public String timuTeacherDetail(HttpServletRequest request, Model model) {
		String id = request.getParameter("id");
		if(id!=null && id !=null && !"".equals(id) && !"0".equals(id)){
			request.setAttribute("id", id);
		}else{
			request.setAttribute("id", "");
		}
		return "/modules/teacher/timu_detail";
	}
	@RequestMapping("wangban-teacher-detail.html")
	public String wangbanTeacherDetail(HttpServletRequest request, Model model) {
		String id = request.getParameter("id");
		if(id!=null && id !=null && !"".equals(id) && !"0".equals(id)){
			request.setAttribute("id", id);
		}else{
			request.setAttribute("id", "");
		}
		return "/modules/teacher/wangban_detail";
	}
	@RequestMapping("wangban-teacher-pingjia.html")
	public String wangbanTeacherPingjia(HttpServletRequest request, Model model) {
		String id = request.getParameter("id");
		if(id!=null && id !=null && !"".equals(id) && !"0".equals(id)){
			request.setAttribute("id", id);
		}else{
			request.setAttribute("id", "");
		}
		return "/modules/teacher/wangban_pingjia";
	}
	@RequestMapping("zhibo-teacher-detail.html")
	public String zhiboTeacherDetail(HttpServletRequest request, Model model) {
		String id = request.getParameter("id");
		if(id!=null && id !=null && !"".equals(id) && !"0".equals(id)){
			request.setAttribute("id", id);
		}else{
			request.setAttribute("id", "");
		}
		return "/modules/teacher/zhibo_detail";
	}
	@RequestMapping("zhibo-teacher-suitangkao.html")
	public String zhiboTeacherSuitangkao(HttpServletRequest request, Model model) {
		return "/modules/teacher/zhibo_suitangkao";
	}
	@RequestMapping("advertising-teacher-detail.html")
	public String advertisingTeacherDetail(HttpServletRequest request, Model model) {
		String id = request.getParameter("id");
		if(id!=null && id !=null && !"".equals(id) && !"0".equals(id)){
			request.setAttribute("id", id);
		}else{
			request.setAttribute("id", "");
		}
		return "/modules/teacher/advertising_detail";
	}
	@RequestMapping("user-add.html")
	public String userAdd(HttpServletRequest request, Model model) {
		return "/modules/jianxue/user_add";
	}
	@RequestMapping("teacher-paper.html")
	public String teacherPaper(HttpServletRequest request, Model model) {
		String id = request.getParameter("id");
		String type = request.getParameter("type");
		if(id!=null && id !=null && !"".equals(id) && !"0".equals(id)){
			request.setAttribute("id", id);
		}else{
			request.setAttribute("id", "");
		}
		if("0".equals(type)){
			Course course = publicService.findCourse(Integer.parseInt(id));
			request.setAttribute("name","课程考试组卷 > "+course.getName());
		}else if("1".equals(type)){
			Online online = publicService.findOnline(Integer.parseInt(id));
			request.setAttribute("name", "微课作业组卷 > "+online.getName());
		}else if("2".equals(type)){
			Live live = publicService.findLive(Integer.parseInt(id));
			request.setAttribute("name", "直播随堂考组卷 > "+live.getName());
		}
		request.setAttribute("type", type);
		return "/modules/teacher/paper";
	}
	@RequestMapping("paper.html")
	public String paper(HttpServletRequest request, Model model) {
		String id = request.getParameter("id");
		String type = request.getParameter("type");
		if(id!=null && id !=null && !"".equals(id) && !"0".equals(id)){
			request.setAttribute("id", id);
		}else{
			request.setAttribute("id", "");
		}
		if("0".equals(type)){
			Course course = publicService.findCourse(Integer.parseInt(id));
			request.setAttribute("name","课程考试组卷 > "+course.getName());
		}else if("1".equals(type)){
			Online online = publicService.findOnline(Integer.parseInt(id));
			request.setAttribute("name", "微课作业组卷 > "+online.getName());
		}else if("2".equals(type)){
			Live live = publicService.findLive(Integer.parseInt(id));
			request.setAttribute("name", "直播随堂考组卷 > "+live.getName());
		}
		request.setAttribute("type", type);
		return "/modules/jianxue/paper";
	}
	@RequestMapping("paper-detail.html")
	public String paperDetail(HttpServletRequest request, Model model) {
		String id = request.getParameter("id");
		String type = request.getParameter("type");
		String resourceId = request.getParameter("resourceId");
		if(id!=null && id !=null && !"".equals(id) && !"0".equals(id)){
			request.setAttribute("id", id);
		}else{
			request.setAttribute("id", "");
		}
		request.setAttribute("type", type);
		request.setAttribute("resourceId", resourceId);
		return "/modules/teacher/paper_detail";
	}
	@RequestMapping("teacher-zujuanzi.html")
	public String teacherZujuanzi(HttpServletRequest request, Model model) {
		String id = request.getParameter("id");
		String type = request.getParameter("type");
		String resourceId = request.getParameter("resourceId");
		if(id!=null && id !=null && !"".equals(id) && !"0".equals(id)){
			request.setAttribute("id", id);
		}else{
			request.setAttribute("id", "");
		}
		request.setAttribute("type", type);
		request.setAttribute("resourceId", resourceId);
		return "/modules/teacher/zujuanzi";
	}
	@RequestMapping("zujuanzi.html")
	public String zujuanzi(HttpServletRequest request, Model model) {
		String id = request.getParameter("id");
		String type = request.getParameter("type");
		String resourceId = request.getParameter("resourceId");
		if(id!=null && id !=null && !"".equals(id) && !"0".equals(id)){
			request.setAttribute("id", id);
		}else{
			request.setAttribute("id", "");
		}
		request.setAttribute("type", type);
		request.setAttribute("resourceId", resourceId);
		return "/modules/jianxue/zujuanzi";
	}
	@RequestMapping("audit.html")
	public String audit(HttpServletRequest request, Model model) {
		String type = request.getParameter("type");
		String resourceId = request.getParameter("resourceId");
		request.setAttribute("type", type);
		request.setAttribute("resourceId", resourceId);
		return "/modules/jianxue/audit";
	}
	@RequestMapping("chatRoom.html")
	public String chatRoom(HttpServletRequest request, Model model) {
		String id = request.getParameter("id");
		if(id!=null && id !=null && !"".equals(id) && !"0".equals(id)){
			request.setAttribute("id", id);
		}else{
			request.setAttribute("id", "");
		}
		return "/modules/teacher/chatRoom";
	}
	@RequestMapping("documentation.html")
	public String documentation(HttpServletRequest request, Model model) {
		return "/modules/jianxue/documentation";
	}
}
